load("@rules_java//java:defs.bzl", "java_library")
load("//:cel_android_rules.bzl", "cel_android_library")

package(
    default_applicable_licenses = [
        "//:license",
    ],
    default_visibility = [
        "//common/internal:__pkg__",
    ],
)

# keep sorted
INTERNAL_SOURCES = [
    "BasicCodePointArray.java",
    "CelCodePointArray.java",
    "CodePointStream.java",
    "Constants.java",
    "EmptyCodePointArray.java",
    "Latin1CodePointArray.java",
    "SupplementalCodePointArray.java",
]

# keep sorted
ENV_VISITOR_SOURCES = [
    "EnvVisitable.java",
    "EnvVisitor.java",
]

# keep sorted
CEL_DESCRIPTOR_POOL_SOURCES = [
    "CelDescriptorPool.java",
    "CombinedDescriptorPool.java",
    "DefaultDescriptorPool.java",
]

java_library(
    name = "internal",
    srcs = INTERNAL_SOURCES,
    tags = [
    ],
    deps = [
        "//:auto_value",
        "//common/annotations",
        "//common/ast",
        "//common/values",
        "//common/values:cel_byte_string",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
        "@maven//:org_antlr_antlr4_runtime",
    ],
)

cel_android_library(
    name = "internal_android",
    srcs = INTERNAL_SOURCES,
    tags = [
    ],
    deps = [
        "//:auto_value",
        "//common/annotations",
        "//common/ast:ast_android",
        "//common/values:cel_byte_string",
        "//common/values:values_android",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:org_antlr_antlr4_runtime",
        "@maven_android//:com_google_guava_guava",
        "@maven_android//:com_google_protobuf_protobuf_javalite",
    ],
)

java_library(
    name = "comparison_functions",
    srcs = ["ComparisonFunctions.java"],
    tags = [
    ],
    deps = [
        "//:auto_value",
        "//common/annotations",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
    ],
)

cel_android_library(
    name = "comparison_functions_android",
    srcs = ["ComparisonFunctions.java"],
    tags = [
    ],
    deps = [
        "//common/annotations",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven_android//:com_google_guava_guava",
    ],
)

java_library(
    name = "converter",
    srcs = [
        "AdaptingTypes.java",
        "BidiConverter.java",
        "Converter.java",
    ],
    # used_by_android
    tags = [
    ],
    deps = [
        "//:auto_value",
        "//common/annotations",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:org_jspecify_jspecify",
    ],
)

java_library(
    name = "errors",
    srcs = ["Errors.java"],
    tags = [
    ],
    deps = [
        "//:auto_value",
        "//common/annotations",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:org_jspecify_jspecify",
    ],
)

DYNAMIC_PROTO_SOURCES = [
    "DynamicProto.java",
    "ProtoAdapter.java",
]

java_library(
    name = "default_instance_message_factory",
    srcs = [
        "DefaultInstanceMessageFactory.java",
        "DefaultInstanceMessageLiteFactory.java",
    ],
    tags = [
    ],
    deps = [
        ":proto_java_qualified_names",
        ":reflection_util",
        "//common/annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

java_library(
    name = "default_instance_message_lite_factory",
    srcs = ["DefaultInstanceMessageLiteFactory.java"],
    tags = [
    ],
    deps = [
        ":reflection_util",
        "//common/annotations",
        "@maven//:com_google_guava_guava",
        "@maven_android//:com_google_protobuf_protobuf_javalite",
    ],
)

java_library(
    name = "dynamic_proto",
    srcs = DYNAMIC_PROTO_SOURCES,
    tags = [
    ],
    deps = [
        ":converter",
        ":proto_lite_adapter",
        ":proto_message_factory",
        ":well_known_proto",
        "//:auto_value",
        "//common:error_codes",
        "//common:options",
        "//common:runtime_exception",
        "//common/annotations",
        "//common/values",
        "//common/values:cel_byte_string",
        "@maven//:com_google_code_findbugs_annotations",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

java_library(
    name = "proto_lite_adapter",
    srcs = ["ProtoLiteAdapter.java"],
    tags = [
    ],
    deps = [
        ":well_known_proto",
        "//common:error_codes",
        "//common:proto_json_adapter",
        "//common:runtime_exception",
        "//common/annotations",
        "//common/values",
        "//common/values:cel_byte_string",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

java_library(
    name = "proto_equality",
    srcs = ["ProtoEquality.java"],
    tags = [
    ],
    deps = [
        ":dynamic_proto",
        "//:auto_value",
        "//common/annotations",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
        "@maven//:org_jspecify_jspecify",
    ],
)

java_library(
    name = "file_descriptor_converter",
    srcs = [
        "FileDescriptorSetConverter.java",
    ],
    tags = [
    ],
    deps = [
        "//:auto_value",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

java_library(
    name = "env_visitor",
    srcs = ENV_VISITOR_SOURCES,
    tags = [
    ],
    deps = [
        "//common/annotations",
        "//parser:macro",
        "@cel_spec//proto/cel/expr:checked_java_proto",
    ],
)

java_library(
    name = "well_known_proto",
    srcs = ["WellKnownProto.java"],
    tags = [
    ],
    deps = [
        "//common/annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

cel_android_library(
    name = "well_known_proto_android",
    srcs = ["WellKnownProto.java"],
    tags = [
    ],
    deps = [
        "//common/annotations",
        "@maven_android//:com_google_guava_guava",
        "@maven_android//:com_google_protobuf_protobuf_javalite",
    ],
)

java_library(
    name = "default_message_factory",
    srcs = ["DefaultMessageFactory.java"],
    tags = [
    ],
    deps = [
        ":cel_descriptor_pools",
        ":default_instance_message_factory",
        ":proto_message_factory",
        "//common/annotations",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

java_library(
    name = "proto_message_factory",
    srcs = ["ProtoMessageFactory.java"],
    tags = [
    ],
    deps = [
        ":cel_descriptor_pools",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

java_library(
    name = "cel_descriptor_pools",
    srcs = CEL_DESCRIPTOR_POOL_SOURCES,
    tags = [
    ],
    deps = [
        ":well_known_proto",
        "//common:cel_descriptors",
        "//common/annotations",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

java_library(
    name = "cel_lite_descriptor_pool",
    srcs = ["CelLiteDescriptorPool.java"],
    tags = [
    ],
    deps = [
        "//protobuf:cel_lite_descriptor",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven_android//:com_google_protobuf_protobuf_javalite",
    ],
)

cel_android_library(
    name = "cel_lite_descriptor_pool_android",
    srcs = ["CelLiteDescriptorPool.java"],
    tags = [
    ],
    deps = [
        "//protobuf:cel_lite_descriptor",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven_android//:com_google_protobuf_protobuf_javalite",
    ],
)

java_library(
    name = "default_lite_descriptor_pool",
    srcs = ["DefaultLiteDescriptorPool.java"],
    tags = [
    ],
    deps = [
        ":cel_lite_descriptor_pool",
        ":well_known_proto",
        "//common/annotations",
        "//protobuf:cel_lite_descriptor",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
        "@maven_android//:com_google_protobuf_protobuf_javalite",
    ],
)

cel_android_library(
    name = "default_lite_descriptor_pool_android",
    srcs = ["DefaultLiteDescriptorPool.java"],
    tags = [
    ],
    deps = [
        ":cel_lite_descriptor_pool_android",
        ":well_known_proto_android",
        "//common/annotations",
        "//protobuf:cel_lite_descriptor",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven_android//:com_google_guava_guava",
        "@maven_android//:com_google_protobuf_protobuf_javalite",
    ],
)

java_library(
    name = "safe_string_formatter",
    srcs = ["SafeStringFormatter.java"],
    # used_by_android
    tags = [
    ],
    deps = [
        "//common/annotations",
        "@maven//:com_google_re2j_re2j",
    ],
)

java_library(
    name = "proto_java_qualified_names",
    srcs = ["ProtoJavaQualifiedNames.java"],
    tags = [
    ],
    deps = [
        "//common/annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

java_library(
    name = "reflection_util",
    srcs = ["ReflectionUtil.java"],
    deps = [
        "//common/annotations",
    ],
)

java_library(
    name = "proto_time_utils",
    srcs = ["ProtoTimeUtils.java"],
    tags = [
    ],
    deps = [
        "//common/annotations",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

cel_android_library(
    name = "proto_time_utils_android",
    srcs = ["ProtoTimeUtils.java"],
    tags = [
    ],
    deps = [
        "//common/annotations",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven_android//:com_google_guava_guava",
        "@maven_android//:com_google_protobuf_protobuf_javalite",
    ],
)
